<template>
  <div>
    <h1>{{ stuMessage }}</h1>
    <h2>学生姓名：{{ stuName }}</h2>
    <h2>学生年龄：{{ stuAge }}</h2>
    <h2>学生性别：{{ stuSex }}</h2>
    <!-- <button @click="sendMessageName">点击按钮给School组件发送学生姓名数据</button> -->
  </div>
</template>

<script>
import pubsub from 'pubsub-js'
export default {
    name:"Student",
    data:function(){
        return{
            stuMessage:"student information",
            stuName:"zhangsan",
            stuAge: 23,
            stuSex:'man'
        }
    },
    //点击触发
    methods:{
      // sendMessageName(){
      //   pubsub.publish("message",this.stuName)
      // }
    },
    mounted(){
      //自动挂载完成时触发
      pubsub.publish("message",this.stuName)
       
    }
}
</script>
<style>

</style>